home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 May / EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso / earcd / util / time / autorebo.lha / AutoReboot / AutoReboot.c < prev    next >
C/C++ Source or Header  |  1996-12-27  |  792b  |  43 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include "functions.h"
  4.  
  5. #define VERSION_NUM "1.0"
  6. #define VERSION_DAT "(27.12.96)"
  7.  
  8. char *version="$VER: AutoReboot "VERSION_NUM" "VERSION_DAT;
  9.  
  10. main(int argc, char * argv[])
  11. {
  12.     FILE * checkfile=NULL;
  13.  
  14.     if(argc!=3)
  15.     {
  16.         printf("AutoReboot "VERSION_NUM" by Ralf Gruner.\nUsage: AutoReboot <filename> <seconds>\n");
  17.         exit(5);
  18.     }
  19.     for(;;)
  20.     {
  21.         Delay(atoi(argv[2])*50);
  22.         if(NULL==(checkfile=fopen(argv[1],"r")))
  23.         {
  24.             /* Falls Datei evtl. gerade geschrieben wird */
  25.             Delay(100);
  26.             if(NULL==(checkfile=fopen(argv[1],"r")))
  27.             {
  28.                 ColdReboot(); // wenn Datei nicht existiert
  29.             }
  30.         }
  31.  
  32.         if(fclose(checkfile)!=0)
  33.         {
  34.             ColdReboot(); // wenn Fehler beim Schließen
  35.         }
  36.         if(remove(argv[1])!=0)
  37.         {
  38.             ColdReboot(); // wenn Fehler beim Löschen
  39.         }
  40.     }
  41. }
  42.  
  43.